package com.foreknow.demo4;

/**
 * static静态：
 */
public class Student {
    public String sname;
    public static int count;

    //静态代码块：主要的作用是用来初始化的，静态代码块是在类被加载的时候自动执行的，只执行一次
    static {
        System.out.println("static code..............");
    }

    //static可以修饰方法
    public static void m1() {
//        Student student = new Student();
//        student.sname = "gibson";
        System.out.println("m1................");
    }

    public static void main(String[] args) {

        Student.m1(); //调用静态方法  类名.静态方法名(参数);

        Student student1 = new Student();
        student1.sname="tom";
        student1.count = 1;

        Student student2 = new Student();
        student2.sname="fender";
        student2.count = 2;

        System.out.println(student1.sname);
        System.out.println(student1.count);
        System.out.println("-----------------------------------------");
        System.out.println(student2.sname);
        System.out.println(student2.count);

        String s = "123";

    }
}
